<?php

namespace MUD;

class Strings{
    protected $strings=array();
    protected $fd;
    
    public function __construct(){
        $this->fd = simplexml_load_file(__ROOT__.DS.'res'.DS.'strings.xml');
        $this->xmlToArr();
    }
    
    protected function xmlToArr(){
        foreach($this->fd->str as $str){
            $this->strings[(string)$str['key']] = str_replace('[nl]', "\n", (string)$str);
        }
    }
    
    public function __get($what){
        if(array_key_exists($what, $this->strings)){
            return $this->strings[$what];
        }else{
            \MUD\R::current()->logger->raiseError("String ".$what." not found.");
            return '';
        }
    }
}